
export function timestampToTime(timestamp) {
    var date = new Date(timestamp); // JavaScript中的时间戳单位是秒，需要乘以1000转换成毫秒
    
    var year = date.getFullYear();
    var month = (date.getMonth() + 1).toString().padStart(2, '0');
    var day = date.getDate().toString().padStart(2, '0');
    var h = date.getHours().toString().padStart(2,'0')
    var m = date.getMinutes().toString().padStart(2,'0')
    var s = date.getSeconds().toString().padStart(2,'0')
    return `${year}-${month}-${day}`+' '+`${h}:${m}:${s}`;
}

export function formatDate(date){
    let year = date.getFullYear()
    let month = (date.getMonth() + 1) < 10?'0'+(date.getMonth()+1):date.getMonth() + 1
    let day = date.getDate() < 10?'0'+date.getDate():date.getDate()
    let hour = date.getHours() < 10?'0'+date.getHours():date.getHours()
    let minute = date.getMinutes() < 10?'0'+date.getMinutes():date.getMinutes()
    // let second = date.getSeconds() < 10?'0'+date.getSeconds():date.getSeconds()
    let nowDate = year + '-' + month + '-' + day
    return nowDate
}
